package com.snopy.thread.thread_base;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author snopy
 * @version 1.0.0
 * @classname ThreadStateTestA
 * @description
 * @email 77912204@qq.com
 * @date 2022/02/20 19:39
 */
@Slf4j
public class ThreadStateTestA {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(()->{
            try {
                synchronized (ThreadStateTestA.class){
                    log.info("线程状态->{}",Thread.currentThread().getState());
                }
                TimeUnit.SECONDS.sleep(3);


            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        },"线程1");
        Thread thread1 = new Thread(()->{
            synchronized (ThreadStateTestA.class){
                try {
                    TimeUnit.SECONDS.sleep(2);
                    log.info("线程1状态->{}",thread.getState());
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

                while (true){

                }
            }

        },"线程2");
        thread1.start();
        thread.start();
        log.info("线程1状态:{}",thread1.getState());


    }
}
